<!doctype html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>商户信息_店铺管理|速定客_预订美好生活！</title>
<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible">
<meta content="外卖信息,中山外卖送餐,网上订餐,-,,速定客,速订客，预订美好生活！外卖订餐美食网" name="keywords">
<meta content="速订客—外卖网，订餐，美食。最好的网上订餐平台，为您提供最新最全的24小时外卖送餐电话、外卖菜单等外卖订餐详细信息。包括肯德基网上订餐电话，麦当劳网上订餐电话。" name="description">
<link rel="stylesheet" type="text/css" href="http://img2.sudingke.com/css/base.css">
<link rel="stylesheet" type="text/css" href="http://img.sudingke.net/css/member/global.css">
<link rel="stylesheet" type="text/css" href="http://img.sudingke.net/css/member/member.css">
<link href="http://img2.sudingke.com/favicon.ico" type="image/x-icon" rel="icon" />
<link href="http://img2.sudingke.com/favicon.ico" type="image/x-icon" rel="shortcut icon" />
<body>
<!-- header start -->
<?php include $this->tpl('c_header'); ?>
<!-- header close -->

<div class="clearfix" id="bd">
  <div id="yao-main">
    <div class="yao-b">
      <?php include $this->tpl('c_news'); ?>
      <div class="mod mod-title" id="ucInfo">
        <form action="?m=biz&c=profile&a=save" id="aform" method="post" autocomplete="off">
          <div class="hd">
            <h2>商户信息</h2>
          </div>
          <div class="bd">
            <div class="info-read">这里填写商户及联系信息。</div>
            <table cellspacing="0" cellpadding="0" border="0" class="table-two">
              <tbody>
                <tr>
                  <th><span class="required">*</span> 店铺名称：</th>
                  <td><input type="text" class="input-m" name="name" id="name" required minlength="4" value="<?=h($data['name']);?>" />
                    <?=showTips($error, '例如：速订客面馆（人民路店）');?></td>
                </tr>
                <tr>
                  <th><span class="required">*</span> 联系人：</th>
                  <td><input type="text" class="input-s" id="contact" name="contact" required minlength="2" value="<?=h($data['contact']);?>" />
                    <?=showTips($error);?></td>
                </tr>
                <tr>
                  <th><span class="required">*</span> 联系电话：</th>
                  <td><input type="text" data-rules="mobile" class="input-s" id="mobile" name="mobile" required value="<?=h($data['mobile']);?>" />
                    <?=showTips($error, '仅用于客服联系，不会出现在店铺界面');?></td>
                </tr>
                <!--tr>
                  <th><span class="required">*</span> 所在区域：</th>
                  <td><select name="city_id">
                      <option>-城市-</option>
                      <option>大连</option>
                    </select>
                    <select name="zone_id">
                      <option>-区县-</option>
                      <option>西岗区</option>
                    </select>
                    <select name="area_id" required min="1">
                      <option value="">-商圈-</option>
                      <option value="212">西安路</option>
                    </select>
                    <?=showTips($error);?></td>
                </tr-->
                <tr>
                  <th><span class="required">*</span> 地址：</th>
                  <td><input type="text" class="input-m" minlength="10" maxlength="200" required name="address" value="<?=h($data['address']);?>" />
                    <?=showTips($error);?></td>
                </tr>
                <tr>
                  <th>地图标注：</th>
                  <td><input type="hidden" required name="longitude" id="longitude" value="<?=h($data['longitude']);?>" />
                    <input type="hidden" required name="latitude" id="latitude" value="<?=h($data['latitude']);?>" />
                    <button id="openMap" type="button"> 在地图中标注位置 </button>
                    <?=showTips($error, '当前地图坐标：'.$data['longitude'].', '.$data['latitude'].')');?>
                  </td>
                </tr>
                <tr>
                  <th valign="top">店铺图片：</th>
                  <td>
                    <input type="hidden" name="picture" id="picture" value="<?=h($data['picture']);?>" />
                    <button id="uploadPic" type="button"> 上传店铺图片/Logo </button> <span class="v-tips"></span>
                    <div style="border:1px #ccc solid;padding:1px;height:150px;width:200px;">
                        <img id="picimage" src="/upfiles/<?=h($data['picture'], 'nopic_200x150.jpg');?>" height="150" width="200" /> </div>
                    </td>
                </tr>
                <tr class="table-ft">
                  <th>&nbsp;</th>
                  <td><div class="ucinfo-row"> <span class="btni04 submit"> <span>
                      <input type="hidden" name="submitform" value="yes">
                      <input type="submit" class=" js-log" hidefocus="true" value="保 存">
                      </span> </span>
                    </div></td>
                </tr>
              </tbody>
            </table>
          </div>
        </form>
        <div>&nbsp;</div>
      </div>
    </div>
  </div>
  <?php include $this->tpl('c_menunav'); ?>
</div>

<!-- footer start -->
<?php include $this->tpl('c_footer'); ?>
<!-- footer close -->

<!--百度地图容器-->
<div id="mapDiv" style="display:none">
  <div style="padding:4px">说明：拖拽蓝色标点设置位置 <span class="fr"> <a id="centerMap">设置到当前位置</a> | <a id="closeMap">确定关闭</a></span> </div>
  <div style="width:697px;height:550px;border:#ccc solid 1px;" id="mapContent"> </div>
</div>
<script src="http://autocar.com/statics/js/jquery.js" language="JavaScript"></script>
<script src="http://autocar.com/statics/js/supe.js" language="JavaScript"></script>
<script type="text/javascript">
$(function(){
  //打开地图
  $("#openMap").click(function(){
    Supe.use('dialog', 'baiduMap', function(){
        $.dialog({
            id:"baiduMap",
            title:"地图标点",
            content:document.getElementById("mapDiv"),
            padding:"0",
            lock:true,
            width:600,
            height:450
        }).show();

        baiduMap.initMap();
    });
  });

  //关闭地图
  $("#closeMap").click(function(){
    $.dialog({id:"baiduMap"}).close();
  });

  //移动到地图中心
  $("#centerMap").click(function(){
    baiduMap.moveIconToCenter();
  });

  //上传图片
  $("#uploadPic").click(function(){
    var upbuttn = this;
    Supe.use('ajaxUpload', function(){
        new AjaxUpload(upbuttn, {
            action: "?m=system&c=upload&a=thumb",
            name: 'thumbdata',
            onSubmit: function (file, ext) {
                if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                    $(upbuttn).parent().find(".v-tips").addClass("v-error").html("仅支持 JPG, PNG 或 GIF 类型");
                    return false;
                }
                $(upbuttn).parent().find(".v-tips").html("正在上传中...");
            },
            onComplete: function (file, response) {
                var data = JSON.parse(response);
                if (data.err === "") {
                    $("#picture").val(data.msg.url);
                    $("#picimage").attr("src", "/upfiles/" + data.msg.url);
                    $(upbuttn).parent().find(".v-tips").addClass("v-valid").html("&nbsp;");
                } else {
                    $(upbuttn).parent().find(".v-tips").addClass("v-error").html(data.err);
                }
            }
        });
    });
  });
});


//Baidu地图操作相关
var map;
var baiduMap = {
    _created : false,
    map : null,
    point: null,
    markerOld: null,
    markerNew: null,

    //创建和初始化地图函数：
    initMap : function(){
        var level = 16;
        var lng = $("#longitude").val();
        var lat = $("#latitude").val();
        if(!lng || !lat){
            lng = 121.593478;
            lat = 38.94871;
            level = 12;
        }
        if(!this._created){
            this.createMap(lng, lat, level);//创建地图
            this.setMapEvent();//设置地图事件
            this.addMapControl();//向地图添加控件
            this.intIconMarker(); //设置标点
            this._created = true
        }
    },

    //创建地图函数：
    createMap : function (lng, lat, level){
        map = new BMap.Map("mapContent");//在百度地图容器中创建一个地图
        this.point = new BMap.Point(lng, lat);//定义一个中心点坐标
        map.centerAndZoom(this.point, level);//设定地图的中心点和坐标并将地图显示在地图容器中
        window.map = map;//将map变量存储在全局
    },

    //地图事件设置函数：
    setMapEvent : function (){
        map.enableDragging();//启用地图拖拽事件，默认启用(可不写)
        map.enableScrollWheelZoom();//启用地图滚轮放大缩小
        map.enableDoubleClickZoom();//启用鼠标双击放大，默认启用(可不写)
        map.enableKeyboard();//启用键盘上下左右键移动地图
    },

    //地图控件添加函数：
    addMapControl : function (){
            //向地图中添加缩放控件
        var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_SMALL});
        map.addControl(ctrl_nav);
            //向地图中添加缩略图控件
        var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_TOP_RIGHT,isOpen:1});
        map.addControl(ctrl_ove);
            //向地图中添加比例尺控件
        var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
        map.addControl(ctrl_sca);
    },


    //设置可以移动的标点
    intIconMarker : function(){
        var iconimg = "http://api.map.baidu.com/library/MarkerTool/1.2/src/images/us_mk_icon.png";
        var iconOld = new BMap.Icon(iconimg, new BMap.Size(23, 25), {anchor: new BMap.Size(9, 25), imageOffset: new BMap.Size(0, -21)});
        var iconNew = new BMap.Icon(iconimg, new BMap.Size(23, 25), {anchor: new BMap.Size(9, 25), imageOffset: new BMap.Size(-23, -21)});

        //覆盖层
        this.markerOld = new BMap.Marker(this.point);
        this.markerNew = new BMap.Marker(this.point);
        this.markerOld.setIcon(iconOld);
        this.markerNew.setIcon(iconNew);
        this.markerNew.enableDragging(); // 设置标注可拖拽

        map.addOverlay(this.markerOld);
        map.addOverlay(this.markerNew);

        var self = this;
        //事件
        this.markerNew.addEventListener("mouseup", function(e){
            var flag = confirm("您确定标注位置？：" + this.getPosition().lng + ", " + this.getPosition().lat);
            if(flag){
                self.markerOld.setPosition(self.markerNew.getPosition());
                $("#longitude").val(this.getPosition().lng);
                $("#latitude").val(this.getPosition().lat)
                $("#openMap").parent().find(".v-tips,.v-error").addClass("v-valid").html("&nbsp;");
            }
        });
    }
}
baiduMap.moveIconToCenter = function(){
    //alert(map.getCenter().lng);
    baiduMap.markerNew.setPosition(map.getCenter());
    baiduMap.markerOld.setPosition(map.getCenter());

    $("#longitude").val(map.getCenter().lng);
    $("#latitude").val(map.getCenter().lat);

    $("#openMap").parent().find(".v-tips,.v-error").addClass("v-valid").html("&nbsp;");
}

</script>
<script type="text/javascript">
$(function(){
  Supe.use('validate', function(){
    $("#aform").validate({
        errorClass:'v-error',
        validClass:'v-valid',
        errorElement: 'span',
        ignore: '',
        groups:{
            'map': "longitude latitude"
        },
        errorPlacement:function(label, element){
            if(element.parent().find('.v-tips'))
                element.parent().find('.v-tips').remove();

            element.parent().append(label);
        },
        success: function(label, element) {
            // set &nbsp; as text for IE
            label.html("&nbsp;").addClass("v-valid");
        },
        messages:{
            'name' : {required: "请填写店铺名称"},
            'contact' : {required: "请填写联系人姓名"},
            'mobile' : {required: "请填写手机号码"},
            'area_id' : {required: "请选择所在区域/商圈", min: "请选择所在区域/商圈"},
            'address' : {required: "请填写店铺地址"},
            'longitude' : {required: "请设置地图标点"},
            'latitude' : {required: "请设置地图标点"}
        }
    });
  });
});
</script>
</body>
</html>

<?php
    function showTips(&$error, $tips = ''){
        if(get_request('submitform')){
            if(isset($error)) printf('<span class="v-error">%s</span>', $error);
            else echo '<span class="v-valid"></span>';
        }else{
            printf('<span class="v-tips">%s</span>', $tips);
        }
    }
?>